package com.ruoyi.project.msgBjk.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.msgBjk.domain.MsgSsjBjk;
import com.ruoyi.project.msgBjk.service.IMsgSsjBjkService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 臂架库（监控）Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@Controller
@RequestMapping("/system/bjk")
public class MsgSsjBjkController extends BaseController
{
    private String prefix = "system/bjk";

    @Autowired
    private IMsgSsjBjkService msgSsjBjkService;

    @GetMapping()
    public String bjk()
    {
        return prefix + "/bjk";
    }

    /**
     * 查询臂架库（监控）列表
     */
    @RequiresPermissions("system:bjk:list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsgSsjBjk msgSsjBjk)
    {
//        startPage();
        List<MsgSsjBjk> list = msgSsjBjkService.selectMsgSsjBjkList(msgSsjBjk);
        return getDataTable(list);
    }

    /**
     * 导出臂架库（监控）列表
     */
    @RequiresPermissions("system:bjk:export")
    @Log(title = "臂架库（监控）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsgSsjBjk msgSsjBjk)
    {
        List<MsgSsjBjk> list = msgSsjBjkService.selectMsgSsjBjkList(msgSsjBjk);
        ExcelUtil<MsgSsjBjk> util = new ExcelUtil<MsgSsjBjk>(MsgSsjBjk.class);
        return util.exportExcel(list, "臂架库（监控）数据");
    }

    /**
     * 新增臂架库（监控）
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存臂架库（监控）
     */
    @RequiresPermissions("system:bjk:add")
    @Log(title = "臂架库（监控）", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsgSsjBjk msgSsjBjk)
    {
        return toAjax(msgSsjBjkService.insertMsgSsjBjk(msgSsjBjk));
    }

    /**
     * 修改臂架库（监控）
     */
    @RequiresPermissions("system:bjk:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MsgSsjBjk msgSsjBjk = msgSsjBjkService.selectMsgSsjBjkById(id);
        mmap.put("msgSsjBjk", msgSsjBjk);
        return prefix + "/edit";
    }

    /**
     * 修改保存臂架库（监控）
     */
    @RequiresPermissions("system:bjk:edit")
    @Log(title = "臂架库（监控）", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsgSsjBjk msgSsjBjk)
    {
        return toAjax(msgSsjBjkService.updateMsgSsjBjk(msgSsjBjk));
    }

    /**
     * 删除臂架库（监控）
     */
    @RequiresPermissions("system:bjk:remove")
    @Log(title = "臂架库（监控）", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msgSsjBjkService.deleteMsgSsjBjkByIds(ids));
    }
}
